﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DAWSharp.FileFormats.WavFile;

namespace DAWSharp.UI.WinFormsControls
{
    public partial class WaveDisplayContainer : UserControl
    {
        private WavFile _wavFile;
        
        public WaveDisplayContainer()
        {
            InitializeComponent();
        }

        public void LoadWavFile(string FilePath)
        {
            _wavFile = new WavFile();
            _wavFile.OpenWavFile(FilePath);

            AddWaveDisplays();

            
        }

        private void AddWaveDisplays()
        {
            if (_wavFile.GetNumberOfChannels() == 1)
            {
                MonoWaveDisplay mono = new MonoWaveDisplay(_wavFile, MonoWaveDisplay.Channel.Mono, false, this.Height)
                {
                    Location = new Point(0, 0),
                    BackColor = Color.LightSkyBlue,
                    ForeColor = Color.DodgerBlue,
                    AutoSize = true
                };
                this.Controls.Add(mono);
            }
            else
            {
                MonoWaveDisplay left = new MonoWaveDisplay(_wavFile, MonoWaveDisplay.Channel.Left, false, this.Height / 2)
                {
                    Location = new Point(0, 0),
                    BackColor = Color.LightSkyBlue,
                    ForeColor = Color.DodgerBlue,
                    AutoSize = true
                };
                this.Controls.Add(left);

                MonoWaveDisplay right = new MonoWaveDisplay(_wavFile, MonoWaveDisplay.Channel.Right, false, this.Height / 2)
                {
                    Location = new Point(0, this.Height / 2),
                    BackColor = Color.LightSkyBlue,
                    ForeColor = Color.DodgerBlue,
                    AutoSize = true
                };
                this.Controls.Add(right);
            }
        }
    }
}
